<?php

class GlobalZoneDao {

    var $connection;

    function GlobalZoneDao($connection) {
        $this->connection = $connection;
    }

    public function create($operator, $ZAG_param) {
        $sql = "INSERT INTO t_zone_autorisee_globale_zag(ZAG_operateur,ZAG_param, ZAG_actif) VALUES(\"$operator\", \"$ZAG_param\", 1) ON DUPLICATE KEY UPDATE ZAG_param=\"$ZAG_param\"";
        $r = $this->connection->query($sql);
        return $r;
        
    }

    public function getZoneByOperator($operator) {
        $r = $this->connection->querySingle("SELECT * FROM t_zone_autorisee_globale_zag WHERE ZAG_operateur= \"$operator\"");
        return $r['ZAG_param'];
    }

    public function findall() {
        return $this->connection->queryAll("SELECT * FROM t_zone_autorisee_globale_zag");
    }

}
